<?php

namespace Common\Models\Videos;

use Phalcon\Mvc\Model;
use Phalcon\Mvc\Model\Validator\Uniqueness;

class VideoCategoryLink extends Model
{
    protected $id;
    
    protected $video_id;

    protected $category_id;

    protected $position;
 

    public function getSource()
    {
        return 'video_category_link';
    }

    public function initialize()
    {
        $this->setSource('video_category_link');


        $this->belongsTo('video_id','Common\Models\Videos\Video','id',array(
            'alias'     =>  'video'
        ));

        $this->belongsTo('category_id','Common\Models\Videos\VideoCategory','id',array(
            'alias'     =>  'category'
        ));
    }
    
    /*
    public function metaData()
    {
        return array(
            //Every column in the mapped table
            MetaData::MODELS_ATTRIBUTES => array(
                'video_id', 'category_id', 'position'
            ),

            //Every column that isn't part of the primary key
            MetaData::MODELS_NON_PRIMARY_KEY => array(
                'video_id', 'category_id' , 'position'
            ),

            //Every column that doesn't allows null values
            MetaData::MODELS_NOT_NULL => array(
                'category_id', 'position'
            ),

            //Every column and their data types
            MetaData::MODELS_DATA_TYPES => array(
                'video_id' => Column::TYPE_INTEGER,
                'category_id' => Column::TYPE_INTEGER,
                'position' => Column::TYPE_INTEGER
            ),

            //The columns that have numeric data types
            MetaData::MODELS_DATA_TYPES_NUMERIC => array(
                'video_id' => true,
                'category_id' => true,
                'position' => true,
            ),

            //The identity column, use boolean false if the model doesn't have
            //an identity column
            MetaData::MODELS_IDENTITY_COLUMN => 'id',

            //How every column must be bound/casted
            MetaData::MODELS_DATA_TYPES_BIND => array(
                'video_id' => Column::BIND_PARAM_INT,
                'category_id' => Column::BIND_PARAM_INT,
                'position' => Column::BIND_PARAM_INT
            ),
           
            //Fields that must be ignored from UPDATE SQL statements
            MetaData::MODELS_AUTOMATIC_DEFAULT_UPDATE => array(
                'video_id' => true,
                'category_id' => true
            )
        );
    }
    */

    /**
     * @return User
     */
    public static function findFirstById($parameters = array())
    {
        return parent::findFirstById($parameters);
    }
    function getId() {
        return $this->id;
    }

    function setId($id) {
        $this->id = $id;
    }

    function getVideoId() {
        return $this->video_id;
    }

    function getCategoryId() {
        return $this->category_id;
    }

    function getPosition() {
        return $this->position;
    }

    function setVideoId($video_id) {
        $this->video_id = $video_id;
        return $this;
    }

    function setCategoryId($category_id) {
        $this->category_id = $category_id;
        return $this;
    }

    function setPosition($position) {
        $this->position = $position;
        return $this;
    }
    
}
